package com.axcbd.demo.controller;


import com.axcbd.demo.dto.response.ApiResponse;
import com.axcbd.demo.model.Acceleration;
import com.axcbd.demo.service.AccelerationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/acceleration")
public class AccelerationController {

    @Autowired
    private AccelerationService accelerationService;

    @GetMapping("/latest/{n}")
    public ResponseEntity<ApiResponse<?>> getLatestNAcceleration(@PathVariable int n){
        List<Acceleration> list = accelerationService.getLatestNAccelerations(n);
        return ResponseEntity.ok(new ApiResponse<>(list));
    }
}
